/*
    SUSAN® - Sole of Unix Save ANything

   

   

   

   
*/

#ifndef BAREOS_LIB_THREAD_LIST_H_
#define BAREOS_LIB_THREAD_LIST_H_ 1

#include <functional>
#include <memory>

class ConfigurationParser;
class ThreadListPrivate;

class ThreadList {
  friend class ThreadGuard;

 public:
  ThreadList();
  ~ThreadList();

  using ThreadHandler =
      std::function<void*(ConfigurationParser* config, void* data)>;
  using ShutdownCallback = std::function<void*(void* data)>;

  void Init(int maximum_thread_count,
            ThreadHandler ThreadInvokedHandler,
            ShutdownCallback ShutdownCallback = nullptr);

  bool CreateAndAddNewThread(ConfigurationParser* config, void* data);
  bool ShutdownAndWaitForThreadsToFinish();
  std::size_t Size() const;

  ThreadList(const ThreadList& ohter) = delete;
  ThreadList(const ThreadList&& ohter) = delete;
  ThreadList& operator=(const ThreadList& rhs) = delete;
  ThreadList& operator=(const ThreadList&& rhs) = delete;

 private:
  std::unique_ptr<ThreadListPrivate> impl_;
};


#endif /* BAREOS_LIB_THREAD_LIST_H_ */
